package com.my.cd.chain;

/**
 * 主测试类
 */
public class MainTest {

    public static void main(String[] args) {
        Client client = new Client();
        Approver groupApprover = new GroupApprover("Tom");
        Approver departmentApprover = new DepartmentApprover("Jerry");
        Approver vicePresidentApprover = new VicePresidentApprover("Kate");
        Approver presidentApprover = new PresidentApprover("Bush");

        //这里的下一个处理者可以是不固定的，调换顺序也是没问题的。
        groupApprover.setNextApprover(departmentApprover);//组长 --> 部门经理
        departmentApprover.setNextApprover(vicePresidentApprover);// 部门经理 --> 副总
        vicePresidentApprover.setNextApprover(presidentApprover);// 副总 --> 总监
        presidentApprover.setNextApprover(groupApprover);//总监 --> 组长

        vicePresidentApprover.processRequest(client.sendRequest(1, 100, 40));
        vicePresidentApprover.processRequest(client.sendRequest(2, 200, 40));
        vicePresidentApprover.processRequest(client.sendRequest(3, 300, 40));
        vicePresidentApprover.processRequest(client.sendRequest(4, 400, 140));
    }
}
